﻿#ifndef MYWORKER_H
#define MYWORKER_H


#include <QObject>
#include<QDebug>
#include<QThread>
 class MyWorker:public QObject                    //work定义了线程要执行的工作
{
     Q_OBJECT
 public:
     MyWorker(QObject* parent = nullptr){}
 public slots:
     void doWork(int parameter)                        //doWork定义了线程要执行的操作
     {
         qDebug()<<"receive the execute signal---------------------------------";
         qDebug()<<"     current thread ID:"<<QThread::currentThreadId();
        for(int i = 0;i!=1000000;++i)
       {
         ++parameter;
        }
        qDebug()<<"finish the work and sent the resultReady signal\n";
        emit resultReady(parameter);           //emit啥事也不干，是给程序员看的，表示发出信号发出信号
     }

 signals:
     void resultReady(const int result);               //线程完成工作时发送的信号
 };

#endif // MYWORKER_H
